<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="90px">
      <el-form-item label="客户姓名" prop="cusName">
        <el-input
            v-model="queryParams.cusName"
            placeholder="请输入客户姓名"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- 省市 -->
        <el-form-item label="省">
            <el-select v-model="queryParams.provinceCode" placeholder="请选择省份" clearable size="small" @change="getCustomCityListFn(2,queryParams.provinceCode)">
                <el-option v-for="item in provinceList" :key="item.id" :label="item.area_name" :value="item.id" />
            </el-select>
            <el-select v-model="queryParams.cityCode" placeholder="请选择市" clearable size="small">
                <el-option v-for="item in cityList" :key="item.id" :label="item.area_name" :value="item.id" />
            </el-select>
        </el-form-item>
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="dateRange"
          size="small"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          class="filter-item"
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
        >搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="客户姓名" align="center" prop="userName" />
        <el-table-column label="总分" align="center" prop="score" />
        <el-table-column label="类型" align="center" prop="grade" />
        <el-table-column label="基本信息分" align="center" prop="baseInfoScore" />
        <el-table-column label="工作项评分" align="center" prop="workInfoScore" />
        <el-table-column label="房产信息分" align="center" prop="houseInfoScore" />
        <el-table-column label="征信信息分" align="center" prop="creditInfoScore" />
        <el-table-column label="负债信息分" align="center" prop="liabilitiesInfoScore" />
        <el-table-column label="创建时间" align="center" prop="createTime" />
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getListFn"
    />
    
    <!-- 操作日志详细 -->
    <el-dialog title="客服评分详情" :visible.sync="open" width="700px" append-to-body>
        <el-form ref="form" :model="form" label-width="100px" size="mini">
            <el-row>
            <el-col :span="12">
                <el-form-item label="请求地址：">{{ form.operUrl }}</el-form-item>
                <el-form-item label="请求方式：">{{ form.requestMethod }}</el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="操作方法：">{{ form.method }}</el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="请求参数：">{{ form.operParam }}</el-form-item>
            </el-col>
            <el-col :span="24">
                <el-form-item label="返回参数：">{{ form.jsonResult }}</el-form-item>
            </el-col>
            </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
            <el-button @click="open = false">关 闭</el-button>
        </div>
    </el-dialog>
  </div>
</template>

<script>
import { axios_getList } from "@/api/system/userGrade";
import { getCustomCityList } from "@/api/system/customer";

export default {
  name: "userGrade",
  data() {
    return {
        productId: '',
        dialogSingle: false,
        proList: [],
        dialogTotal: 0,
        dialogLoading: false,
        dialogParams: {
            pageNum: 1,
            pageSize: 10
        },
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 公司信息表格数据
      infoList: [],
      // 日期范围
      dateRange: [],
      search: '',
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        accumulateType: undefined,
        orderNum: undefined,
        areaCode: undefined,
        leader: undefined,
        phone: undefined,
        email: undefined,
        status: undefined,
      },
      // 表单参数
      form: {
        provinceObj: undefined,
        cityObj: undefined,
      },
        provinceList: [],
        cityList: [],
        checkedInfo: null,
    };
  },
  created() {
    this.getListFn();
    this.getCustomCityListFn(1, null);
  },
  methods: {
    /** 查询公司信息列表 */
    getListFn() {
        this.loading = true;
        if(this.dateRange === null){
            this.dateRange = ['',''];
        }
        this.queryParams.begTime = this.dateRange[0];
        this.queryParams.endTime = this.dateRange[1];
        axios_getList(this.queryParams).then(response => {
            this.infoList = response.rows;
            this.total = response.total;
            this.loading = false;
        });
    },


    // 获取当前用户的省市
    getCustomCityListFn(type,id){
        getCustomCityList({leveType: type,parentId: id}).then(res => {
            if(res.code === 'success'){
                if(type === 1){
                    this.provinceList = res.data;
                }else if(type === 2){
                    this.cityList = res.data;
                    this.queryParams.cityCode = '';
                }
            }
        });
    },
    
    //  类型
    getType(type){
        // 0:充值 1:订单消费 2:分享码 3:提现 4:人工充值
        switch(type){
            case 0:
                return '新增';
            break;
            case -1:
                return '作废';
            break;
            case 1:
                return '认领';
            break;
            case 2:
                return '生成订单';
            break;
        }
    },
    
    /** 详细按钮操作 */
    handleView(row) {
      this.open = true;
      this.form = row;
    },
    
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getListFn();
    },
    
    // 多选框选中数据
    handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!=1
        this.multiple = !selection.length;
        this.checkedInfo = selection[0];
    },
  }
};
</script>